/*
 *  Copyright 2003 jRPM Team
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
using System;
using java = biz.ritter.javapi;

namespace com.jguild.jrpm.io.constant
{


    /**
     * Constants for index type.
     *
     * @version $Id: RPMIndexType.java,v 1.3 2003/10/20 16:32:12 mkuss Exp $
     */
    public sealed class RPMIndexType : EnumIf
    {
        public static readonly RPMIndexType UNKNOWN = new RPMIndexType(EnumIfConstants._UNKNOWN, "UNKNOWN", 0);
        public const int _NULL = 0;
        public static readonly RPMIndexType NULL = new RPMIndexType(_NULL, "NULL", 0);
        public const int _CHAR = 1;
        public static readonly RPMIndexType CHAR = new RPMIndexType(_CHAR, "CHAR", 1);
        public const int _INT8 = 2;
        public static readonly RPMIndexType INT8 = new RPMIndexType(_INT8, "INT8", 1);
        public const int _INT16 = 3;
        public static readonly RPMIndexType INT16 = new RPMIndexType(_INT16, "INT16", 2);
        public const int _INT32 = 4;
        public static readonly RPMIndexType INT32 = new RPMIndexType(_INT32, "INT32", 4);
        public const int _INT64 = 5;
        public static readonly RPMIndexType INT64 = new RPMIndexType(_INT64, "INT64", 8);
        public const int _STRING = 6;
        public static readonly RPMIndexType STRING = new RPMIndexType(_STRING, "STRING", 1);
        public const int _BIN = 7;
        public static readonly RPMIndexType BIN = new RPMIndexType(_BIN, "BIN", 1);
        public const int _STRING_ARRAY = 8;
        public static readonly RPMIndexType STRING_ARRAY = new RPMIndexType(_STRING_ARRAY, "STRING_ARRAY", 1);
        public const int _I18NSTRING = 9;
        public static readonly RPMIndexType I18NSTRING = new RPMIndexType(_I18NSTRING, "I18NSTRING", 1);
        private EnumIf delegateJ;
        private int size;

        private RPMIndexType(int type, String name, int size)
        {
            delegateJ = new EnumDelegate(typeof(RPMIndexType), type, name, this);
            this.size = size;
        }

        /**
         * Get a enum by id
         *
         * @param id The id of the enum
         * @return The enum object
         */
        public static EnumIf getEnumById(long id)
        {
            return EnumDelegate.getEnumById(typeof(RPMIndexType), id);
        }

        /**
         * Get a enum by name
         *
         * @param name The name of the enum
         * @return The enum object
         */
        public static EnumIf getEnumByName(String name)
        {
            return EnumDelegate.getEnumByName(typeof(RPMIndexType), name);
        }

        /**
         * Get all defined enums of this class
         *
         * @return An array of all defined enum objects
         */
        public static String[] getEnumNames()
        {
            return EnumDelegate.getEnumNames(typeof(RPMIndexType));
        }

        /**
         * Get a enum of this class by id
         *
         * @param type The id
         * @return The enum object
         */
        public static RPMIndexType getRPMIndexType(long type)
        {
            RPMIndexType result = (RPMIndexType)getEnumById(type);
            if (result == null)
            {
                switch (type)
                {
                    case _NULL:
                        result = NULL;
                        break;
                    case _CHAR:
                        result = CHAR; 
                        break;
                    case _INT8: 
                        result = INT8; 
                        break;
                    case _INT16: 
                        result = INT16; 
                        break;
                    case _INT32: 
                        result = INT32; 
                        break;
                    case _INT64: 
                        result = INT64; 
                        break;
                    case _STRING: 
                        result = STRING; 
                        break;
                    case _BIN: 
                        result = BIN; 
                        break;
                    case _STRING_ARRAY: 
                        result = STRING_ARRAY; 
                        break;
                    case _I18NSTRING: 
                        result = I18NSTRING; 
                        break;
                    default:
                        result = UNKNOWN
                            ; break;
                }
            }
    
            return result;
        }

        /**
         * Get the size of this enum in byte
         *
         * @return The size in byte
         */
        public int getSize()
        {
            return size;
        }

        /**
         * Check if this enum class contains a enum of a specified id
         *
         * @param id The id of the enum
         * @return TRUE if the enum is defined in this class
         */
        public static bool containsEnumId(java.lang.Long id)
        {
            return EnumDelegate.containsEnumId(typeof(RPMIndexType), id);
        }

        /*
         * @see com.jguild.jrpm.io.constant.EnumIf#getId()
         */
        public long getId()
        {
            return delegateJ.getId();
        }

        /*
         * @see com.jguild.jrpm.io.constant.EnumIf#getName()
         */
        public String getName()
        {
            return delegateJ.getName();
        }

        /*
         * @see java.lang.Object#toString()
         */
        public override String ToString()
        {
            return delegateJ.toString();
        }
    }
}